package model

import (
	"gitee.com/xuxinzhi2206/corehub/database/mysql"
	"gorm.io/gorm"
)

// 商品属性值表
type GoodsPropertyValue struct {
	gorm.Model
	PropertyId int64  `gorm:"column:property_id;type:int(11)" json:"property_id"`
	Name       string `gorm:"column:name;type:varchar(255)" json:"name"`
}

func (g *GoodsPropertyValue) GetGoodsPropertyValueByPropertyId(propertyIds []int64) (list []*GoodsPropertyValue, err error) {
	err = mysql.WithMysql(func(db *gorm.DB) error {
		return db.Model(g).Where("property_id in(?)", propertyIds).Find(&list).Error
	})
	return
}

func (g *GoodsPropertyValue) GetGoodsPropertyValueByPId(propertyId int64) (list *GoodsPropertyValue, err error) {
	err = mysql.WithMysql(func(db *gorm.DB) error {
		return db.Model(g).Where("id =?", propertyId).Find(&list).Error
	})
	return
}
